package com.blb.eduadservice.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blb.common.entity.PromotionAd;
import com.blb.eduadservice.mapper.PromotionAdMapper;
import com.blb.eduadservice.service.IPromotionAdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 广告表 服务实现类
 * </p>
 *
 * @author xray
 * @since 2023-03-31
 */
@Service
public class PromotionAdServiceImpl extends ServiceImpl<PromotionAdMapper, PromotionAd> implements IPromotionAdService {

    @Resource
    private PromotionAdMapper promotionAdMapper;

    @Cacheable(cacheNames = "ad",key = "T(String).valueOf(#spaceId)")
    @Override
    public List<PromotionAd> getAdBySpaceId(Long spaceId) {
        List<PromotionAd> ads = promotionAdMapper.selectList(new QueryWrapper<PromotionAd>().lambda().eq(PromotionAd::getSpace_id, spaceId));
        return ads;
    }
}
